/**
 * 
 */
package com.et114.modules.products.brands.services;

import java.util.List;

import com.et114.components.simpletable.DataList;
import com.et114.core.services.impl.BaseServicesImpl;
import com.et114.core.utility.FileUploadUtil;
import com.et114.modules.products.brands.dao.BrandDao;
import com.et114.modules.products.brands.vo.Brand;

/*
 * @author guanhw
 */
public class BrandServiceImpl extends BaseServicesImpl {
	private BrandDao	brandDao;

	public void setBrandDao ( BrandDao brandDao ) {
		this.brandDao = brandDao;
	}
	
	public DataList getBrands ( Brand vo ) throws Exception {
		return brandDao.getBrands ( vo ) ; 
	}
	
	public List< Brand > getBrandList( Brand vo ) throws Exception {
		return  brandDao.getBrandList ( vo ) ;
	}
	
	
	public Brand getBrandById( Long brandId ) throws Exception {
		return brandDao.getBrandById ( brandId ) ;
	}
	
	public Long saveBrand( Brand vo ) throws Exception {
		return ( Long  ) brandDao.saveBrand ( vo ) ; 
	}
	
	public void updateBrand( Brand vo ) throws Exception {
		brandDao.updateBrand ( vo ) ;
	}
		
	public void removeBrandById( Long brandId ) throws Exception {
		Brand brand = getBrandById( brandId  ) ; 
		if ( brand != null ) {
			FileUploadUtil.removeFile ( brand.getImagePath ( ) ) ; 
			brandDao.removeBrandById ( brandId ) ; 
		}
	}
}
